package  gearunits.models{
	import org.papervision3d.core.math.NumberUV;
	import org.papervision3d.core.math.Number3D;
	import org.papervision3d.core.geom.renderables.Triangle3D;
	import org.papervision3d.core.geom.renderables.Vertex3D;
	import org.papervision3d.core.geom.TriangleMesh3D;
	import org.papervision3d.core.proto.MaterialObject3D;

	public class PMeshBaseTurret extends TriangleMesh3D {
		private var ve:Array;
		private var fa:Array;

		public function PMeshBaseTurret(material : MaterialObject3D ) {
			super( material, new Array(), new Array() );
			ve = this.geometry.vertices;
			fa = this.geometry.faces;
			v(8.000000,-0.800000,8.000000);
			v(8.000000,-0.800000,-8.000000);
			v(-8.000001,-0.800000,-7.999998);
			v(-7.999996,-0.800000,8.000003);
			v(8.000004,0.800000,7.999996);
			v(7.999995,0.800000,-8.000005);
			v(-8.000003,0.800000,-7.999997);
			v(-7.999999,0.800000,8.000000);
			v(-2.160000,5.720000,4.200000);
			v(-2.160001,5.720000,-10.199998);
			v(2.159999,5.720000,-10.200005);
			v(2.160001,5.720000,4.199997);
			v(-2.159999,4.280000,4.200003);
			v(-2.160000,4.280000,-10.199999);
			v(2.160000,4.280000,-10.200001);
			v(2.160000,4.280000,4.200000);

			f(15,14,13,0.501376,0.949037,0.500000,0.500413,0.634587,0.500000,0.000000,0.000000,-1.000000);
			f(15,13,12,0.501376,0.949037,0.634587,0.500000,0.635963,0.948624,0.000000,-0.000000,-1.000000);
			f(11,8,9,0.637340,0.500000,0.771927,0.500413,0.770551,0.949037,-0.000000,0.000000,1.000000);
			f(11,9,10,0.637340,0.500000,0.770551,0.949037,0.635964,0.948624,0.000000,-0.000000,1.000000);
			f(15,11,14,0.402385,0.500138,0.447247,0.500000,0.403761,0.948762,1.000000,0.000000,-0.000001);
			f(11,10,14,0.447247,0.500000,0.448624,0.948624,0.403761,0.948762,1.000000,-0.000000,0.000001);
			f(14,10,13,0.357110,0.500138,0.401972,0.500000,0.357523,0.634725,-0.000000,-1.000000,-0.000003);
			f(10,9,13,0.401972,0.500000,0.402385,0.634587,0.357523,0.634725,-0.000002,-1.000000,0.000001);
			f(13,9,8,0.000000,0.500138,0.044862,0.500000,0.046239,0.948624,-1.000000,0.000000,-0.000000);
			f(13,8,12,0.000000,0.500138,0.046239,0.948624,0.001376,0.948762,-1.000000,0.000000,-0.000001);
			f(11,15,12,0.091514,0.634587,0.046652,0.634725,0.046239,0.500138,0.000001,1.000000,0.000002);
			f(11,12,8,0.091514,0.634587,0.046239,0.500138,0.091101,0.500000,0.000001,1.000000,0.000002);
			f(4,0,7,0.926056,0.998471,0.876209,0.998624,0.924527,0.500000,0.000000,1.000000,0.000002);
			f(0,3,7,0.876209,0.998624,0.874680,0.500153,0.924527,0.500000,0.000000,1.000000,0.000002);
			f(2,6,7,0.773456,0.500000,0.823303,0.500153,0.821774,0.998624,-1.000000,0.000000,-0.000001);
			f(2,7,3,0.773456,0.500000,0.821774,0.998624,0.771927,0.998471,-1.000000,0.000000,-0.000002);
			f(1,5,2,0.824833,0.500000,0.874680,0.500153,0.823303,0.998471,-0.000000,-1.000000,-0.000003);
			f(5,6,2,0.874680,0.500153,0.873150,0.998624,0.823303,0.998471,-0.000000,-1.000000,0.000001);
			f(0,4,1,0.448624,0.500153,0.498471,0.500000,0.450153,0.998624,1.000000,0.000000,-0.000002);
			f(4,5,1,0.498471,0.500000,0.500000,0.998471,0.450153,0.998624,1.000000,-0.000001,0.000003);
			f(4,7,5,0.501529,0.000000,1.000000,0.001529,0.500000,0.498471,-0.000000,-0.000000,1.000000);
			f(7,6,5,1.000000,0.001529,0.998471,0.500000,0.500000,0.498471,0.000000,-0.000000,1.000000);
			f(0,1,2,0.001529,0.500000,0.000000,0.001529,0.498471,0.000000,0.000000,0.000000,-1.000000);
			f(0,2,3,0.001529,0.500000,0.498471,0.000000,0.500000,0.498471,0.000000,-0.000000,-1.000000);

			this.x = 0.000000;
			this.y = 0.000000;
			this.z = 0.000000;

			this.rotationX = 0.000000;
			this.rotationY = 0.000000;
			this.rotationZ = 0.000000;

			this.scaleX = 1.000000;
			this.scaleY = 1.000000;
			this.scaleZ = 1.000000;

			this.geometry.ready = true;
		}
		public function v(x:Number, y:Number, z:Number):void {
			ve.push(new Vertex3D(x, y, z));
		}

		public function f(vertexIndex1:Number, vertexIndex2:Number, vertexIndex3:Number, uv00:Number, uv01:Number, uv10:Number, uv11:Number, uv20:Number, uv21:Number, normalx:Number, normaly:Number, normalz:Number):void {
			var face : Triangle3D = new Triangle3D(this, [ve[vertexIndex1], ve[vertexIndex2], ve[vertexIndex3]], null, [ new NumberUV(uv00, uv01), new NumberUV(uv10, uv11), new NumberUV(uv20, uv21) ] );
			face.faceNormal = new Number3D(normalx,normaly,normalz);
			fa.push(face);
		}

		public function f2(vertexIndex1:Number, vertexIndex2:Number, vertexIndex3:Number):void {
			var face:Triangle3D = new Triangle3D(this, [ve[vertexIndex1], ve[vertexIndex2], ve[vertexIndex3]], null, []);
			fa.push(face);
		}

	}
}